﻿<UserControl
    
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:MoneyManagerNET.Presentation.ViewModel;assembly=MoneyManagerNET.Presentation.ViewModel"
             xmlns:MoneyManagerNET_Presentation="clr-namespace:MoneyManagerNET.Presentation" 
			 x:Class="MoneyManagerNET.Presentation.View.BankAccountView" 
			 xmlns:UserControls="clr-namespace:MoneyManagerNET.Presentation"
             mc:Ignorable="d"
             d:DesignHeight="290" d:DesignWidth="382" 
             d:DataContext="{x:Static vm:DesignTimeViewModelSupplier.BankAccount}"
    
            mc:Ignorable="PresentationOptions"
            xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
    >    
    
    <UserControl.Resources>
    	<ContextMenu x:Key="filterMenu" ItemsSource="{Binding FilterList}" DisplayMemberPath="Title" >
    		<ContextMenu.Resources>
    			<Style TargetType="{x:Type MenuItem}">
    				<EventSetter Event="MenuItem.Click" Handler="MenuItem_Click"/>
    			</Style>
    		</ContextMenu.Resources>
    	</ContextMenu>
    	<Color x:Key="Blue">Blue</Color>
    </UserControl.Resources>
    <Grid >
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="Hovered">
    			<VisualState x:Name="MouseOver"/>
    		</VisualStateGroup>
    	</VisualStateManager.VisualStateGroups>
        <Grid.RowDefinitions>
        	<RowDefinition Height="Auto" />
        	<RowDefinition Height="*" />
        	<RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel>
            
            <StackPanel Orientation="Horizontal" >
               
                <TextBlock Text="Account View: " FontSize="18"/>
                <TextBlock Text="{Binding Name}" FontSize="18"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
            	<UserControls:ArrowButton Height="16" Width="16" Mouse.MouseDown="Grid_MouseDown" RenderTransformOrigin="0.5,0.5">
            		<UserControls:ArrowButton.LayoutTransform>
            			<TransformGroup>
            				<ScaleTransform ScaleX="2"/>
            				<SkewTransform/>
            				<RotateTransform/>
            				<TranslateTransform/>
            			</TransformGroup>
            		</UserControls:ArrowButton.LayoutTransform>
            		<UserControls:ArrowButton.RenderTransform>
            			<TransformGroup>
            				<ScaleTransform ScaleY="2"/>
            				<SkewTransform/>
            				<RotateTransform/>
            				<TranslateTransform/>
            			</TransformGroup>
            		</UserControls:ArrowButton.RenderTransform>
            	</UserControls:ArrowButton>
                <TextBlock Text="View "/>
                <TextBlock Text="{Binding Filter.Title}"/>
            </StackPanel>
            
            <TextBlock>
                <TextBlock.Text >
                    <MultiBinding StringFormat="Account balance: $ {0}   Reconciled balance: $ {1}">
                        <Binding Path="AccountBalance"/>
                        <Binding Path="ReconciledBalance"/>                        
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
            
        </StackPanel>
        <DataGrid   Background="White" AutoGenerateColumns="False" EnableRowVirtualization="True" AlternatingRowBackground="AliceBlue" ItemsSource="{Binding Transactions}" x:Name="transactionSetDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" Grid.Row="1" CanUserAddRows="False" IsReadOnly="True" IsSynchronizedWithCurrentItem="True">
            <DataGrid.Columns>
            	<DataGridTemplateColumn x:Name="accountColumn" Header="Account" Width="SizeToHeader">
            		<DataGridTemplateColumn.CellTemplate>
            			<DataTemplate>
            				<StackPanel Orientation="Horizontal">
            					<TextBlock Text="{Binding FromAccount.Name}" Foreground="Red"/>
            					<TextBlock Text="-&gt;"/>
            					<TextBlock Text="{Binding ToAccount.Name}" Foreground="Green"/>
            				</StackPanel>
            			</DataTemplate>
            		</DataGridTemplateColumn.CellTemplate>
            	</DataGridTemplateColumn>
            	<DataGridTextColumn x:Name="statusColumn"  Header="Status" Width="SizeToHeader" >
            		<DataGridTextColumn.Binding>
            			<Binding Path="Status" >
            				<Binding.Converter>
            					<vm:TransactionStatusConverter/>
            				</Binding.Converter>
            			</Binding>
            		</DataGridTextColumn.Binding>
            	</DataGridTextColumn>
            	<DataGridTextColumn x:Name="idColumn" Binding="{Binding Id}" Header="Id" Width="SizeToHeader" />

            	<DataGridTemplateColumn x:Name="categoryColumn" Header="Category" Width="Auto">
            		<DataGridTemplateColumn.CellTemplate>
            			<DataTemplate>
            				<StackPanel Orientation="Horizontal">
            					<TextBlock Text="{Binding Category.Name}" />
            					<TextBlock Text=" : "/>
            					<TextBlock Text="{Binding SubCategory.Name}" />
            				</StackPanel>
            			</DataTemplate>
            		</DataGridTemplateColumn.CellTemplate>
            	</DataGridTemplateColumn>

            	<DataGridTextColumn x:Name="amountColumn" Binding="{Binding Amount}" Header="Amount" Width="SizeToHeader" />
            	<DataGridTemplateColumn x:Name="dateColumn" Header="Date" Width="Auto">
            		<DataGridTemplateColumn.CellTemplate>
            			<DataTemplate>
            				<TextBlock Text="{Binding Date, StringFormat=\{0:d\}}"/>
            			</DataTemplate>
            		</DataGridTemplateColumn.CellTemplate>
            	</DataGridTemplateColumn>
            	<DataGridTextColumn x:Name="contragentColumn" Binding="{Binding Contragent.Name}" Header="Contragent" Width="SizeToHeader" />
                
            </DataGrid.Columns>
        </DataGrid>
        <Grid Grid.Row="2">
            <Grid.Resources>
            	<Style TargetType="{x:Type Button}" >
            		<Setter Property="Margin" Value="10,4"/>
            	</Style>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
            	<ColumnDefinition Width="*"/>
            	<ColumnDefinition Width="*"/>
            	<ColumnDefinition Width="*"/>
            	<ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button  Command="{Binding NewCommand}" IsEnabled="{Binding CanCreateNew}" Content="New">
            	<Button.Foreground>
            		<SolidColorBrush Color="{DynamicResource Green}"/>
            	</Button.Foreground></Button>
            <Button Grid.Column="1" Command="{Binding EditCommand}" Content="Edit">
            	<Button.Foreground>
            		<SolidColorBrush Color="{DynamicResource Edit}"/>
            	</Button.Foreground></Button>
            <Button Grid.Column="2" Command="{Binding DeleteCommand}" Content="Delete">
            	<Button.Foreground>
            		<SolidColorBrush Color="{DynamicResource Red}"/>
            	</Button.Foreground></Button>
				
				<Button Grid.Column="3" Command="{Binding MoveCommand}" Content="Move">
            	<Button.Foreground>
            		<SolidColorBrush Color="{DynamicResource Blue}"/>
            	</Button.Foreground></Button>
        </Grid>
    </Grid>
</UserControl>
